# Maintainer: @naveen521kk on Github, Naveen M K <naveen@syrusdark.website>

_pyname=jaraco.envs
_realname=jaraco.envs
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.1.1
pkgrel=1
pkgdesc='Classes for orchestrating Python (virtual) environments (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://pypi.org/project/jaraco.envs/"
license=('MIT')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python-path"
  "${MINGW_PACKAGE_PREFIX}-python-virtualenv"
  "${MINGW_PACKAGE_PREFIX}-python-tox"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
)
source=(
  "${_pyname}-${pkgver}.tar.gz::https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz"
  "0001-mingw-python-fix.patch"
)
sha256sums=('b40723ae23833e54f2183cfd4b64dcf73ec7f61f24935b9f2d2e227e524e40ba'
            '73ad74505c0cc0cc0a07e1f69b6ad045d62dc50011cfa847e023745510332270')

prepare() {  
  cd "$srcdir"
  cd "${_pyname//_/-}-$pkgver"
  patch -p1 -i ${srcdir}/0001-mingw-python-fix.patch
  cd "${srcdir}"
  rm -rf python-build-${CARCH} | true
  cp -r "${_pyname//_/-}-$pkgver" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
